﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using XYTXL.API;
using XYTXL.AppCode;
using XYTXL.Data;

namespace XYTXL.Web.View.UCMangForm
{
    public partial class XMGL : FormUControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
             
            }
        }




        /// <summary>
        /// 新增时验证栏目重复
        /// </summary>
        /// <param name="strActionType"></param>
        /// <returns></returns>
        public override string VerifyAddForm(string strActionType)
        {
            //int TopId = Convert.ToInt32(ddlTopID.SelectedValue);
            //JH_MH_LMGL Model = new JH_MH_LMGLB().GetEntity(p => p.TopID == TopId && p.Name == txtName.Text && p.IsDel == 0);

            //string strMsg = string.Empty;
            //if (Model != null)
            //{
            //    strMsg = "此栏目已经存在！";
            //}
            return "";
        }
        /// <summary>
        /// 修改时验证栏目重复
        /// </summary>
        /// <param name="intFormID"></param>
        /// <param name="strActionType"></param>
        /// <returns></returns>
        public override string VerifyUpdateForm(int intFormID)
        {
            //int TopId = Convert.ToInt32(ddlTopID.SelectedValue);
            //JH_MH_LMGL Model = new JH_MH_LMGLB().GetEntity(p => p.TopID == TopId && p.Name == txtName.Text && p.IsDel == 0 && p.ID != intFormID);

            //string strMsg = string.Empty;
            //if (Model != null)
            //{
            //    strMsg = "此栏目已经存在！";
            //}
            return "";
        }


        /// <summary>
        /// 重写父类的保存数据方法
        /// </summary>
        /// <param name="intFormID">数据ID</param>
        /// <param name="strActionType">操作类型("ADD":"添加","UPDATE":"修改")</param>
        /// <returns></returns>
        public override bool SaveForm(int intFormID, string strActionType, int pid)
        {
            //执行 父类的方法
            base.SaveForm(intFormID, strActionType);

            //保存数据
            xy_jzxmlb Model = new xy_jzxmlbB().GetEntity(d => d.ID == intFormID);

            Model.xmdm = txtXMBH.Text;
            Model.xmmc = txtName.Text;
            Model.xmsm = txtDetails.Text;
            Model.mxfs = txtThank.Text;
            Model.fqdw = txtCorp.Text;
            Model.xmlxr = txtCon.Text;
            return new xy_jzxmlbB().Update(Model);
        }




        public override void initMangerForm(int intFormID, string strActionType)
        {
            base.initMangerForm(intFormID, strActionType);

            xy_jzxmlb Model = new xy_jzxmlbB().GetEntity(d => d.ID == intFormID);
            txtXMBH.Text = Model.xmdm;
            txtName.Text = Model.xmmc;
            txtDetails.Text = Model.xmsm;
            txtThank.Text = Model.mxfs;
            txtCorp.Text = Model.fqdw;
            txtCon.Text = Model.xmlxr;
        }

        
    }
}